<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>lucky3</title>
    <style>
        #my-lucky {
            margin: 0 auto;
        }

        button {
            display: block;
            margin: 20px auto 0;
        }
    </style>
</head>

<body>
    <div id="my-lucky"></div>
    <button id="btn">开始抽奖</button>


</body>
<script src="https://cdn.jsdelivr.net/npm/lucky-canvas@1.7.11"></script>
<script>
    const btn = document.getElementById('btn');
    btn.addEventListener('click', function () {
        myLucky.play()
        setTimeout(() => {
            myLucky.stop(5)
        }, 1000)

    })
    const myLucky = new LuckyCanvas.SlotMachine('#my-lucky', {
        width: '340px',
        height: '320px',
        blocks: [{
            padding: '10px',
            background: '#e9e8fe'
        }, ],
        slots: [{
                speed: 3,
                direction: 1
            },
            {
                speed: 3,
                direction: -1
            },
            {
                speed: 3,
                direction: 1
            },

        ],
        prizes: [{
                background: '#bac5ee',
                borderRadius: '10px',
                imgs: [{
                    src: './img/aqy.png',
                    width: '100px',
                    height: '100px'
                }],
                fonts: [{
                    text: 0,
                    lineHeight: '100px'
                    // lineHeight: 1
                }]
            },
            {
                background: 'red',
                borderRadius: '10px',
                fonts: [{
                    text: 1,
                    lineHeight: '60px'
                    // lineHeight: 1
                }]
            },
            {
                background: 'orange',
                borderRadius: '10px',
                fonts: [{
                    text: 2,
                    lineHeight: '60px'
                }]
            },
            {
                background: 'blue',
                borderRadius: '10px',
                fonts: [{
                    text: 3,
                    lineHeight: '60px'
                    // lineHeight: 1
                }]
            },
            {
                background: 'yellow',
                borderRadius: '10px',
                fonts: [{
                    text: 4,
                    lineHeight: '60px'
                    // lineHeight: 1
                }]
            },
            {
                background: 'green',
                borderRadius: '10px',
                fonts: [{
                    text: 5,
                    lineHeight: '60px'
                    // lineHeight: 1
                }]
            },
        ],
        defaultConfig: {
            // rowSpacing: '20px',
            colSpacing: '10px',
            accelerationTime:5000, // 游戏刚开始, 会在 2500 ms 内, 从 0 加速到 20
            decelerationTime: 5000 //当你调用 stop 方法后, 会在 2500ms 内速度从 20 降到 0
        },
        end: function (button) {
            console.log(button)
        }
    })
</script>

</html>